module Salsa.Lexer where
import Text.ParserCombinators.Parsec
import Text.ParserCombinators.Parsec.Token as T
import Text.ParserCombinators.Parsec.Language (emptyDef)


salsa = emptyDef {
          commentStart = "/*"
        , commentEnd = "*/"
        , commentLine = ";"
        , nestedComments = False
        , identStart = letter <|> extChar
        , identLetter = letter <|> digit <|> extChar
        , caseSensitive = False
        }

extChar :: Parser Char
extChar = oneOf "!$#%&|*+-/:<=>?@^_~"

lexer :: TokenParser ()
lexer = makeTokenParser (salsa)

whiteSpace = T.whiteSpace lexer
theSymbol  = T.symbol lexer
symbol     = T.identifier lexer
string     = T.stringLiteral lexer
integer    = T.integer lexer
dot        = lx $ char '.'
quote      = lx $ char '\''
opParen    = lx $ char '('
clParen    = lx $ char ')'

lx     = T.lexeme lexer
